package com.studies.mycenter.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.studies.common.R.R;
import com.studies.mycenter.pojo.Activity;
import com.studies.mycenter.service.ActivityService;
import com.studies.mycenter.vo.ActivityDetailsVo;
import com.studies.mycenter.vo.ActivityVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 研学活动 前端控制器
 * </p>
 *
 * @author 研学活动后台
 * @since 2019-12-24
 */
@Api(tags="后台活动模块")
@CrossOrigin //跨域
@RestController
@RequestMapping("/mycenter/activity")
public class ActivityController {
    @Autowired
    private ActivityService activityService;
    @ApiOperation(value = "分页活动列表")
    @GetMapping(value = "{page}/{limit}")
    public R selectPage(  @ApiParam(name = "page", value = "当前页码", required = true)
                              @PathVariable Long page,
                          @ApiParam(name = "limit", value = "每页记录数", required = true)
                              @PathVariable Long limit,
                          @ApiParam(name = "activityVo", value = "条件", required = false)
                               ActivityVo activityVo){

        Page<Activity> pageParam = new Page<Activity>(page, limit);

        Map<String, Object> map = activityService.selectPage(pageParam,activityVo);

        return  R.ok().data(map);
    }

    @ApiOperation(value = "活动信息")
    @GetMapping(value = "{studiesid}")
    public R selectPage(  @ApiParam(name = "studiesid", value = "活动id", required = true)
                          @PathVariable Integer studiesid
                       ){
        ActivityDetailsVo activityDetailsVo = activityService.activityDetails(studiesid);

        return  R.ok().data("itms",activityDetailsVo);
    }
}

